<!--
@author cairq@ucweb.com
-->
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>User-Agent Test</title>
        <script type="text/javascript">
            function parseUserAgent(){
                document.getElementById("actionType").value = "ua";
                document.forms[0].submit();
            }
            
            function parseXUCBrowserUA(){
                document.getElementById("actionType").value = "xua";
                document.forms[0].submit();
            }
            
            function clearData(){
                document.getElementById("text").value = "";
                document.getElementById("parsetResult").value = "";
            }
        </script>
    </head>
    <body>
        <?php
            require_once '../useragent/UserAgentFactory.php';
            $actionType = "";
            $text = "";
            $parsetResult = "";
            if(isset($_POST['actionType'])){
                $actionType = $_POST['actionType'];
                $text = $_POST['text'];
                if($actionType == "ua"){
                    $ua = UserAgentFactory::createUserAgent($text);
                    $parsetResult = $ua->toString();
                } else if($actionType == "xua"){
                    $ua = UserAgentFactory::createXUCBrowserUserAgent($text);
                    $parsetResult = $ua->toString();
                }
            }
        ?>
        <form id="testForm" action="GUITest.php" method="post">
            <input type="hidden" name="actionType" id="actionType"/>
            Please input data:
            <textarea rows="5" style="width: 100%" name="text" id="text"><?=$text?></textarea>
            <button onclick="parseUserAgent();">Parse User-Agent</button>
            <button onclick="parseXUCBrowserUA();">Parse X-UCBrowser-UA</button>
            <button onclick="clearData();">Clear</button>
            <br>
            Parse result:
            <textarea rows="45" style="width: 100%" name="parsetResult" id="parsetResult" readonly="readonly"><?=$parsetResult?></textarea>
        </form>
    </body>
</html>
